home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / eXec / Pokazac obrazek / datatype1.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  2KB  |  104 lines

  1. /* Îadowanie i wyôwietlanie obrazka przez datatypes.library - wersja 1 */
  2. /* Grzegorz Kraszewski, eXec */
  3.  
  4.  
  5. #define __NOLIBBASE__
  6.  
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/intuition.h>
  10. #include <proto/datatypes.h>
  11. #include <proto/graphics.h>
  12. #include <datatypes/pictureclass.h>
  13.  
  14.  
  15. struct Library *SysBase, *IntuitionBase, *DataTypesBase, *GfxBase;
  16.  
  17.  
  18. BOOL OpenLibs (void)
  19.  {
  20.   if (!(IntuitionBase = OpenLibrary ("intuition.library", 39))) return FALSE;
  21.   if (!(DataTypesBase = OpenLibrary ("datatypes.library", 39))) return FALSE;
  22.   if (!(GfxBase = OpenLibrary ("graphics.library", 39))) return FALSE;
  23.   return TRUE;
  24.  }
  25.  
  26.  
  27. void CloseLibs (void)
  28.  {
  29.   if (DataTypesBase) CloseLibrary (DataTypesBase);
  30.   if (IntuitionBase) CloseLibrary (IntuitionBase);
  31.   if (GfxBase) CloseLibrary (GfxBase);
  32.   return;
  33.  }
  34.  
  35.  
  36. int main (void)
  37.  {
  38.   BOOL ok = TRUE;
  39.   Object *picture;
  40.   LONG width, height;
  41.   struct Window *okno;
  42.  
  43.   if (ok = OpenLibs ())
  44.    {
  45.     if (picture = NewDTObject ("PROGDIR:obrazek", DTA_GroupID, GID_PICTURE,
  46.      PDTA_Remap, TRUE, TAG_END))
  47.      {
  48.      GetDTAttrs (picture,
  49.        DTA_NominalHoriz,       (LONG)&width,
  50.        DTA_NominalVert,        (LONG)&height,
  51.        TAG_END);
  52.  
  53.       if (okno = OpenWindowTags (NULL,
  54.        WA_InnerWidth,     width,
  55.        WA_InnerHeight,    height,
  56.        WA_DragBar,        TRUE,
  57.        WA_CloseGadget,    TRUE,
  58.        WA_Activate,       TRUE,
  59.        WA_SmartRefresh,   TRUE,
  60.        WA_IDCMP,          IDCMP_CLOSEWINDOW,
  61.        WA_Title,          (LONG)"Przykîad 1",
  62.        TAG_END))
  63.        {
  64.         struct IntuiMessage *msg;
  65.         struct BitMap *bm;
  66.         LONG msgclass;
  67.         BOOL run = TRUE;
  68.  
  69.         DoDTMethod (picture, NULL, NULL, DTM_PROCLAYOUT, NULL, DTSIF_NEWSIZE);
  70.         GetDTAttrs (picture, PDTA_DestBitMap, (LONG)&bm, TAG_END);
  71.  
  72.         if (bm) BltBitMapRastPort (bm, 0, 0, okno->RPort, okno->BorderLeft,
  73.          okno->BorderTop, width, height, 0xC0);
  74.  
  75.         while (run)
  76.          {
  77.           WaitPort (okno->UserPort);
  78.           while (msg = (struct IntuiMessage*)GetMsg (okno->UserPort))
  79.            {
  80.             msgclass = msg->Class;
  81.             ReplyMsg ((struct Message*)msg);
  82.             if (msgclass == IDCMP_CLOSEWINDOW) run = FALSE;
  83.            }
  84.          }
  85.  
  86.         CloseWindow (okno);
  87.        }
  88.  
  89.       DisposeDTObject (picture);
  90.      }
  91.     else ok = FALSE;
  92.    }
  93.   CloseLibs ();
  94.  
  95.   if (ok) return 0;
  96.   else
  97.    {
  98.     printf ("bîâd\n");
  99.     return 10;
  100.    }
  101.  }
  102.  
  103.  
  104.